package com.atguigu.gmall.controller;


import com.alibaba.fastjson.JSONObject;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.client.ItemFeignClient;
import com.atguigu.gmall.product.client.ProductFeignClient;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;
import java.util.Map;

/**
 * ClassName: ItemController
 * Package: com.atguigu.gmall.controller
 * Description:
 *
 * @Author 刘轩
 * @Create 2023-08-22 18:40
 * @Version 1.0
 */

@Controller
@SuppressWarnings("all")
public class ItemController {
 @Autowired
 private ItemFeignClient itemFeignClient;





 /**
  * 渲染商品详情页面
  *
  * @param skuId
  * @return
  */
 @GetMapping("/{skuId}.html")
 public String getItem(@PathVariable Long skuId, Model model){
  // 调用详情微服务获取渲染详情页面所有的数据
  Result<Map> itemAllData = itemFeignClient.getItemAllData(skuId);
  model.addAllAttributes(itemAllData.getData());
  return "item/item";
 }



}

